 package com.myrobot.util;
 
 import java.awt.Graphics;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
 import javax.imageio.ImageIO;
 
 public class ImageUtil
 {
   public static BufferedImage createImage(String path)
   {
     BufferedImage image = null;
     if (path != null) {
       try {
         image = ImageIO.read(new FileInputStream(path));
       }
       catch (FileNotFoundException e) {
         e.printStackTrace();
       }
       catch (IOException e) {
         e.printStackTrace();
       }
     }
     return image;
   }
   
   public static BufferedImage createImage(InputStream input) {
     BufferedImage image = null;
     if (input != null) {
       try {
         image = ImageIO.read(input);
       }
       catch (FileNotFoundException e) {
         e.printStackTrace();
       }
       catch (IOException e) {
         e.printStackTrace();
       }
     }
     return image;
   }
   
   
   public static BufferedImage createImage(URL url)
   {
     BufferedImage image = null;
     if (url != null) {
       try {
         image = ImageIO.read(url);
       }
       catch (FileNotFoundException e) {
         e.printStackTrace();
       }
       catch (IOException e) {
         e.printStackTrace();
       }
     }
     return image;
   }
   
   public static void write(BufferedImage im, String formatName, OutputStream output) {
     try {
       ImageIO.write(im, formatName, output);
     }
     catch (IOException e) {
       e.printStackTrace();
     }
   }
   
   public static void write(BufferedImage im, String formatName, String file) {
     try {
       ImageIO.write(im, formatName, new File(file));
     }
     catch (IOException e) {
       e.printStackTrace();
     }
   }
   
   public static BufferedImage compressImage(BufferedImage src, int w, int h) {
     BufferedImage out = new BufferedImage(w, h, 1);
     out.getGraphics().drawImage(src.getScaledInstance(w, h, 4), 0, 0, null);
     return out;
   }
   
   public static Boolean compressImage(BufferedImage src, BufferedImage out, int w, int h) {
     return Boolean.valueOf(out.getGraphics().drawImage(src.getScaledInstance(w, h, 4), 0, 0, null));
   }
   
   public static ImageSize getSize(BufferedImage im) {
     ImageSize size = new ImageSize();
     if (im != null) {
       size.setWidth(im.getWidth());
       size.setHeight(im.getHeight());
     }
     return size;
   }
   
   public static class ImageSize {
     private int width = 0;
     private int height = 0;
     
     public int getWidth() {
       return this.width;
     }
     
     public void setWidth(int width) {
       this.width = width;
     }
     
     public int getHeight() {
       return this.height;
     }
     
     public void setHeight(int height) {
       this.height = height;
     }
   }
 }


/* Location:              F:\runnable\yijieRobot.jar!\com\yijierobot\ImageUtil.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */